<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCartsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('carts', function (Blueprint $table) {
            $table->increments('id');
            $table->string('__raw_id')->comment('内部用于区别商品的id');
            $table->integer('user_id')->nullable()->comment('用户id');
            $table->integer('goods_id')->comment('商品id');
            $table->string('channel')->nullable()->comment('商品来源表');
            $table->string('name')->comment('商品名称');
            $table->integer('qty')->comment('数量');
            $table->decimal('price')->comment('商品单价');
            $table->decimal('total')->comment('商品总价');
            $table->text('attributes')->nullable()->comment('附加属性 JSON');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('carts');
    }
}
